<template>
    <div>
        <liGangModal v-if="visible=='liGangModalRef'" ref="liGangModalRef" :linkName="linkName" :formData="formData" @success="success"></liGangModal>
        <jiaBanModal v-if="visible=='jiaBanModalRef'" ref="jiaBanModalRef" :linkName="linkName" :formData="formData" @success="success"></jiaBanModal>
        <qingJiaModal v-if="visible=='qingJiaModalRef'" ref="qingJiaModalRef" :linkName="linkName" :formData="formData" @success="success"></qingJiaModal>
        <xingZhengShenPiModal v-if="visible=='xingZhengShenPiRef'" ref="xingZhengShenPiRef" :linkName="linkName" :formData="formData" @success="success"></xingZhengShenPiModal>
        <xuanCuanXinXiModal v-if="visible=='xuanCuanXinXiRef'" ref="xuanCuanXinXiRef" :linkName="linkName" :formData="formData" @success="success"></xuanCuanXinXiModal>
        <huiYiShiModal v-if="visible=='huiYiShiModalRef'" ref="huiYiShiModalRef" :linkName="linkName" :formData="formData" @success="success"></huiYiShiModal>
        <banGongYongPinModal v-if="visible=='banGongYongPinModalRef'" ref="banGongYongPinModalRef" :linkName="linkName" :Mxlist="Mxlist" :formData="formData" @success="success"></banGongYongPinModal>
        <personalWagesModal v-if="visible=='personalWagesModalRef'" ref="personalWagesModalRef"></personalWagesModal>
        <chuChaiModal v-if="visible=='chuChaiModalRef'" ref="chuChaiModalRef" :linkName="linkName" :formData="formData" @success="success"></chuChaiModal>
        <ziXunYuYueModal v-if="visible=='ziXunYuYueModalRef'" ref="ziXunYuYueModalRef" :linkName="linkName" :formData="formData" @success="success"></ziXunYuYueModal>

        <specialMatter ref="specialMatterRef" @success="success"/>
    </div>
</template>
<script>
import liGangModal from '../departureRequest/index/applicationForm.vue'
import jiaBanModal from '../workOvertime/index/applicationForm.vue'
import qingJiaModal from '../holiday/index/applicationForm.vue'
import xingZhengShenPiModal from '../applyFor/index/applicationForm.vue'
import xuanCuanXinXiModal from '../websiteInformation/index/applicationForm.vue'
import huiYiShiModal from '../conferenceRoomManagement/index/applicationForm.vue'
import banGongYongPinModal from '../officeSupplies/index/applicationForm.vue'
import personalWagesModal from '../wages/personalLogs/applicationForm.vue'
import chuChaiModal from '../onBusiness/index/applicationForm.vue'
import ziXunYuYueModal from '../consultationAppointment/increase.vue'

import specialMatter from '../specialMatter/index'
export default {
    components: {
        liGangModal,jiaBanModal,qingJiaModal,xingZhengShenPiModal,xuanCuanXinXiModal,
        huiYiShiModal,banGongYongPinModal,personalWagesModal,chuChaiModal,ziXunYuYueModal,
        specialMatter
    },
    data() {
        return {
            linkName: '',
            formData: {},
            Mxlist: [],
            addType: [
                {type: '离岗',hjmc: '离岗申请',ref: 'liGangModalRef'},
                {type: '加班',hjmc: '申请',ref: 'jiaBanModalRef'},
                {type: '请假',hjmc: '请假申请',ref: 'qingJiaModalRef'},
                {type: '行政',hjmc: '起草',ref: 'xingZhengShenPiRef'},
                {type: '宣传',hjmc: '申请',ref: 'xuanCuanXinXiRef'},
                {type: '会议室',hjmc: '申请确认',ref: 'huiYiShiModalRef'},
                {type: '办公用品',hjmc: '申请',ref: 'banGongYongPinModalRef'},
                {type: '工资条',hjmc: '申请',ref: 'personalWagesModalRef'},
                {type: '出差',hjmc:'出差申请',ref:'chuChaiModalRef'},
                {type: '咨询预约',hjmc:'咨询预约',ref:'ziXunYuYueModalRef'},

                {type: '特殊事项',hjmc:'申请',ref:'specialMatterRef'}
            ],
            visible: ''
        }
    },
    methods: {
        addClick(type){
            let nameRef = ''
            this.addType.forEach(item => {
                if(item.type == type){
                    nameRef = item.ref
                    this.visible = nameRef
                    this.$nextTick(_ => {
                        this.$refs[nameRef].applicationFormVisible = true
                        this.linkName = item.hjmc
                    })
                }
            })
        },
        modalClick(row){
            //console.log(row)
            let nameRef = row.pageMap.ref
            this.visible = nameRef
            if(nameRef == 'ziXunYuYueModalRef'){
                this.$nextTick(_ => {
                  this.$refs[nameRef].getData(row.oaMap.id)
                  this.$refs[nameRef].applicationFormVisible = true
                  this.linkName = row.hjmc
                  this.formData = {
                      ...row.oaMap,
                      oaid: row.oaMap.id,
                      jobid: row.jobMap?row.jobMap.id:''
                  }
              })
              return
            }
            if(nameRef == 'specialMatterRef'){
                this.$nextTick(_ => {
                  this.$refs[nameRef].getData(row)
                  this.$refs[nameRef].visible = true
              })
              return
            }
            this.$nextTick(_ => {
                this.$refs[nameRef].applicationFormVisible = true
                this.linkName = row.hjmc
                this.formData = {
                    ...row.oaMap,
                    oaid: row.oaMap.id,
                    jobid: row.jobMap?row.jobMap.id:''
                }
                this.Mxlist = row.mxList?row.mxList:[]
            })
        },
        success(){
            //console.log('success-resetEvent')
            this.$emit('resetEvent')
        }
    },
}
</script>
